/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf.bean.client;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import model.client.CasteBeans;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class CasteBean_c {
        private int caste_Id;
        private String caste_Name;
        private int caste_Status;

    public int getCaste_Id() {
        return caste_Id;
    }

    public void setCaste_Id(int caste_Id) {
        this.caste_Id = caste_Id;
    }

    public String getCaste_Name() {
        return caste_Name;
    }

    public void setCaste_Name(String caste_Name) {
        this.caste_Name = caste_Name;
    }

    public int getCaste_Status() {
        return caste_Status;
    }

    public void setCaste_Status(int caste_Status) {
        this.caste_Status = caste_Status;
    }
        
        
    /**
     * Creates a new instance of CasteBean_c
     */
    public CasteBean_c() {
    }
    
    Connection conn;
        
        public List<CasteBeans> loadCaste()throws SQLException, ClassNotFoundException{
        conn = JDBCUtil.MyConn.getConnection();
        
        List<CasteBeans> list = new ArrayList<CasteBeans>();
        
        String sql ="select * from Castes";
        
        PreparedStatement pst = conn.prepareStatement(sql);
        ResultSet rs = pst.executeQuery();
        while(rs.next()){
            CasteBeans cb = new CasteBeans();
            cb.setCaste_Id(rs.getInt("Caste_Id"));
            cb.setCaste_Name(rs.getNString("Caste_Name"));
            list.add(cb);
        }
        return list;
    }
}
